package kt

import com.salton123.utils.task.ThreadQueue
import com.hjq.toast.ToastUtils
import com.netease.yunxin.app.im.BaseApplication
import com.netease.yunxin.kit.alog.ALog

/**
 * Time:2022/1/29 5:18 上午
 * Author:
 * Description:
 */
fun Any.executeByCached(task: () -> Unit) {
    ThreadQueue.execOnCache {
        task.invoke()
    }
}

fun Any.executeByIo(task: () -> Unit) {
    ThreadQueue.post {
        task.invoke()
    }
}

fun Any.runOnUi(task: () -> Unit) {
    ThreadQueue.postOnUi {
        task.invoke()
    }
}

fun Any.log(msg: String) {
    ALog.i("eleph-compressor", msg)
}

fun Any.toast(msg: String) {
    runOnUi {
        ToastUtils.show(msg)
    }
}

fun Int.toast() {
    runOnUi {
        ToastUtils.show(BaseApplication.app().getString(this))
    }
}


fun Int.getString(): String {
    return BaseApplication.app().getString(this)
}


fun Int.getColor(): Int {
    return BaseApplication.app().resources.getColor(this)
}